package net.apexes.demo.codegen.ormlite.column;

import net.apexes.commons.ormlite.Column;
import net.apexes.commons.ormlite.Index;
import net.apexes.demo.codegen.ormlite.column.base.QEntityBase;
import net.apexes.demo.codegen.ormlite.entity.AuthUser;

/**
 * QAuthUser is a ORMLite query type for AuthUser
 * @see AuthUser
 */
public class QAuthUser extends QEntityBase<AuthUser> {

    public static final QAuthUser $ = new QAuthUser("AUTH_USER");

    public final Column username = field("username").columnName("USERNAME").varchar(16).notNull().build();

    public final Column password = field("password").columnName("PASSWORD").varchar(32).notNull().build();

    public final Column nikeName = field("nikeName").columnName("NIKE_NAME").varchar(32).build();

    public final Column email = field("email").columnName("EMAIL").varchar(48).build();

    public final Column mobileNumber = field("mobileNumber").columnName("MOBILE_NUMBER").varchar(16).build();

    public class Indexs {

        public final Index primaryKeyF = index("PRIMARY_KEY_F").unique().column(id).build();

    }

    public final Indexs ix = new Indexs();

    public QAuthUser(String tableName) {
        super(AuthUser.class, tableName);
    }

    @Override
    public AuthUser newInstance() {
        return new AuthUser();
    }

    @Override
    public Object getFieldValue(AuthUser instance, String fieldName) {
        switch (fieldName) {
            case "username":
                return instance.getUsername();
            case "password":
                return instance.getPassword();
            case "nikeName":
                return instance.getNikeName();
            case "email":
                return instance.getEmail();
            case "mobileNumber":
                return instance.getMobileNumber();
            default:
                return super.getFieldValue(instance, fieldName);
        }
    }

    @Override
    public void setupFieldValue(AuthUser instance, String fieldName, Object value) {
        switch (fieldName) {
            case "username":
                instance.setUsername((java.lang.String) value);
                break;
            case "password":
                instance.setPassword((java.lang.String) value);
                break;
            case "nikeName":
                instance.setNikeName((java.lang.String) value);
                break;
            case "email":
                instance.setEmail((java.lang.String) value);
                break;
            case "mobileNumber":
                instance.setMobileNumber((java.lang.String) value);
                break;
            default:
                super.setupFieldValue(instance, fieldName, value);
                break;
        }
    }

}

